package net.huashitong.synthetical.newSupervision.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import net.huashitong.synthetical.newSupervision.entity.TaskLog;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ling
 * Date: 2019/7/2
 * Time: 21:01
 * To change this template use File | Settings | File Templates.
 * Description:
 */
@Repository
public class TaskLogDao extends StringDao<TaskLog> {
    public List<TaskLog> queryByTableId(String id) {
        GenericQuery query = createQuery("obj");
        query.append(" and tableId =:tableId").setParam("tableId", id);
        query.append(" order by sysId");
        return query.listResult();
    }

    public void deleteByTaskIds(List<String> ids) {
        StringBuffer hql = (new StringBuffer("delete from TaskLog")).append(" obj where obj.tableId in(:taskIds)");
        Query query = this.getSession().createQuery(hql.toString());
        query.setParameterList("taskIds", ids);
        query.executeUpdate();
    }
}
